Upload dataset

library(AmesHousing)
ames = make_ames()

ames 
head(ames)
# gives first six observations 
# good for checking that all variables you want are in data set and for looking at type of variables 
str(ames)
## tibble [2,930 × 81] (S3: tbl_df/tbl/data.frame)
##  $ MS_SubClass       : Factor w/ 16 levels "One_Story_1946_and_Newer_All_Styles",..: 1 1 1 1 6 6 12 12 12 6 ...
##  $ MS_Zoning         : Factor w/ 7 levels "Floating_Village_Residential",..: 3 2 3 3 3 3 3 3 3 3 ...
##  $ Lot_Frontage      : num [1:2930] 141 80 81 93 74 78 41 43 39 60 ...
##  $ Lot_Area          : int [1:2930] 31770 11622 14267 11160 13830 9978 4920 5005 5389 7500 ...
##  $ Street            : Factor w/ 2 levels "Grvl","Pave": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Alley             : Factor w/ 3 levels "Gravel","No_Alley_Access",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ Lot_Shape         : Factor w/ 4 levels "Regular","Slightly_Irregular",..: 2 1 2 1 2 2 1 2 2 1 ...
##  $ Land_Contour      : Factor w/ 4 levels "Bnk","HLS","Low",..: 4 4 4 4 4 4 4 2 4 4 ...
##  $ Utilities         : Factor w/ 3 levels "AllPub","NoSeWa",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Lot_Config        : Factor w/ 5 levels "Corner","CulDSac",..: 1 5 1 1 5 5 5 5 5 5 ...
##  $ Land_Slope        : Factor w/ 3 levels "Gtl","Mod","Sev": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Neighborhood      : Factor w/ 29 levels "North_Ames","College_Creek",..: 1 1 1 1 7 7 17 17 17 7 ...
##  $ Condition_1       : Factor w/ 9 levels "Artery","Feedr",..: 3 2 3 3 3 3 3 3 3 3 ...
##  $ Condition_2       : Factor w/ 8 levels "Artery","Feedr",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ Bldg_Type         : Factor w/ 5 levels "OneFam","TwoFmCon",..: 1 1 1 1 1 1 5 5 5 1 ...
##  $ House_Style       : Factor w/ 8 levels "One_and_Half_Fin",..: 3 3 3 3 8 8 3 3 3 8 ...
##  $ Overall_Qual      : Factor w/ 10 levels "Very_Poor","Poor",..: 6 5 6 7 5 6 8 8 8 7 ...
##  $ Overall_Cond      : Factor w/ 10 levels "Very_Poor","Poor",..: 5 6 6 5 5 6 5 5 5 5 ...
##  $ Year_Built        : int [1:2930] 1960 1961 1958 1968 1997 1998 2001 1992 1995 1999 ...
##  $ Year_Remod_Add    : int [1:2930] 1960 1961 1958 1968 1998 1998 2001 1992 1996 1999 ...
##  $ Roof_Style        : Factor w/ 6 levels "Flat","Gable",..: 4 2 4 4 2 2 2 2 2 2 ...
##  $ Roof_Matl         : Factor w/ 8 levels "ClyTile","CompShg",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ Exterior_1st      : Factor w/ 16 levels "AsbShng","AsphShn",..: 4 14 15 4 14 14 6 7 6 14 ...
##  $ Exterior_2nd      : Factor w/ 17 levels "AsbShng","AsphShn",..: 11 15 16 4 15 15 6 7 6 15 ...
##  $ Mas_Vnr_Type      : Factor w/ 5 levels "BrkCmn","BrkFace",..: 5 4 2 4 4 2 4 4 4 4 ...
##  $ Mas_Vnr_Area      : num [1:2930] 112 0 108 0 0 20 0 0 0 0 ...
##  $ Exter_Qual        : Factor w/ 4 levels "Excellent","Fair",..: 4 4 4 3 4 4 3 3 3 4 ...
##  $ Exter_Cond        : Factor w/ 5 levels "Excellent","Fair",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ Foundation        : Factor w/ 6 levels "BrkTil","CBlock",..: 2 2 2 2 3 3 3 3 3 3 ...
##  $ Bsmt_Qual         : Factor w/ 6 levels "Excellent","Fair",..: 6 6 6 6 3 6 3 3 3 6 ...
##  $ Bsmt_Cond         : Factor w/ 6 levels "Excellent","Fair",..: 3 6 6 6 6 6 6 6 6 6 ...
##  $ Bsmt_Exposure     : Factor w/ 5 levels "Av","Gd","Mn",..: 2 4 4 4 4 4 3 4 4 4 ...
##  $ BsmtFin_Type_1    : Factor w/ 7 levels "ALQ","BLQ","GLQ",..: 2 6 1 1 3 3 3 1 3 7 ...
##  $ BsmtFin_SF_1      : num [1:2930] 2 6 1 1 3 3 3 1 3 7 ...
##  $ BsmtFin_Type_2    : Factor w/ 7 levels "ALQ","BLQ","GLQ",..: 7 4 7 7 7 7 7 7 7 7 ...
##  $ BsmtFin_SF_2      : num [1:2930] 0 144 0 0 0 0 0 0 0 0 ...
##  $ Bsmt_Unf_SF       : num [1:2930] 441 270 406 1045 137 ...
##  $ Total_Bsmt_SF     : num [1:2930] 1080 882 1329 2110 928 ...
##  $ Heating           : Factor w/ 6 levels "Floor","GasA",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ Heating_QC        : Factor w/ 5 levels "Excellent","Fair",..: 2 5 5 1 3 1 1 1 1 3 ...
##  $ Central_Air       : Factor w/ 2 levels "N","Y": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Electrical        : Factor w/ 6 levels "FuseA","FuseF",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ First_Flr_SF      : int [1:2930] 1656 896 1329 2110 928 926 1338 1280 1616 1028 ...
##  $ Second_Flr_SF     : int [1:2930] 0 0 0 0 701 678 0 0 0 776 ...
##  $ Low_Qual_Fin_SF   : int [1:2930] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Gr_Liv_Area       : int [1:2930] 1656 896 1329 2110 1629 1604 1338 1280 1616 1804 ...
##  $ Bsmt_Full_Bath    : num [1:2930] 1 0 0 1 0 0 1 0 1 0 ...
##  $ Bsmt_Half_Bath    : num [1:2930] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Full_Bath         : int [1:2930] 1 1 1 2 2 2 2 2 2 2 ...
##  $ Half_Bath         : int [1:2930] 0 0 1 1 1 1 0 0 0 1 ...
##  $ Bedroom_AbvGr     : int [1:2930] 3 2 3 3 3 3 2 2 2 3 ...
##  $ Kitchen_AbvGr     : int [1:2930] 1 1 1 1 1 1 1 1 1 1 ...
##  $ Kitchen_Qual      : Factor w/ 5 levels "Excellent","Fair",..: 5 5 3 1 5 3 3 3 3 3 ...
##  $ TotRms_AbvGrd     : int [1:2930] 7 5 6 8 6 7 6 5 5 7 ...
##  $ Functional        : Factor w/ 8 levels "Maj1","Maj2",..: 8 8 8 8 8 8 8 8 8 8 ...
##  $ Fireplaces        : int [1:2930] 2 0 0 2 1 1 0 0 1 1 ...
##  $ Fireplace_Qu      : Factor w/ 6 levels "Excellent","Fair",..: 3 4 4 6 6 3 4 4 6 6 ...
##  $ Garage_Type       : Factor w/ 7 levels "Attchd","Basment",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Garage_Finish     : Factor w/ 4 levels "Fin","No_Garage",..: 1 4 4 1 1 1 1 3 3 1 ...
##  $ Garage_Cars       : num [1:2930] 2 1 1 2 2 2 2 2 2 2 ...
##  $ Garage_Area       : num [1:2930] 528 730 312 522 482 470 582 506 608 442 ...
##  $ Garage_Qual       : Factor w/ 6 levels "Excellent","Fair",..: 6 6 6 6 6 6 6 6 6 6 ...
##  $ Garage_Cond       : Factor w/ 6 levels "Excellent","Fair",..: 6 6 6 6 6 6 6 6 6 6 ...
##  $ Paved_Drive       : Factor w/ 3 levels "Dirt_Gravel",..: 2 3 3 3 3 3 3 3 3 3 ...
##  $ Wood_Deck_SF      : int [1:2930] 210 140 393 0 212 360 0 0 237 140 ...
##  $ Open_Porch_SF     : int [1:2930] 62 0 36 0 34 36 0 82 152 60 ...
##  $ Enclosed_Porch    : int [1:2930] 0 0 0 0 0 0 170 0 0 0 ...
##  $ Three_season_porch: int [1:2930] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Screen_Porch      : int [1:2930] 0 120 0 0 0 0 0 144 0 0 ...
##  $ Pool_Area         : int [1:2930] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Pool_QC           : Factor w/ 5 levels "Excellent","Fair",..: 4 4 4 4 4 4 4 4 4 4 ...
##  $ Fence             : Factor w/ 5 levels "Good_Privacy",..: 5 3 5 5 3 5 5 5 5 5 ...
##  $ Misc_Feature      : Factor w/ 6 levels "Elev","Gar2",..: 3 3 2 3 3 3 3 3 3 3 ...
##  $ Misc_Val          : int [1:2930] 0 0 12500 0 0 0 0 0 0 0 ...
##  $ Mo_Sold           : int [1:2930] 5 6 6 4 3 6 4 1 3 6 ...
##  $ Year_Sold         : int [1:2930] 2010 2010 2010 2010 2010 2010 2010 2010 2010 2010 ...
##  $ Sale_Type         : Factor w/ 10 levels "COD","Con","ConLD",..: 10 10 10 10 10 10 10 10 10 10 ...
##  $ Sale_Condition    : Factor w/ 6 levels "Abnorml","AdjLand",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ Sale_Price        : int [1:2930] 215000 105000 172000 244000 189900 195500 213500 191500 236500 189000 ...
##  $ Longitude         : num [1:2930] -93.6 -93.6 -93.6 -93.6 -93.6 ...
##  $ Latitude          : num [1:2930] 42.1 42.1 42.1 42.1 42.1 ...
##  - attr(*, "spec")=List of 2
##   ..$ cols   :List of 82
##   .. ..$ Order          : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ PID            : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ MS SubClass    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ MS Zoning      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Lot Frontage   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Lot Area       : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Street         : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Alley          : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Lot Shape      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Land Contour   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Utilities      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Lot Config     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Land Slope     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Neighborhood   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Condition 1    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Condition 2    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Bldg Type      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ House Style    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Overall Qual   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Overall Cond   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Year Built     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Year Remod/Add : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Roof Style     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Roof Matl      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Exterior 1st   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Exterior 2nd   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Mas Vnr Type   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Mas Vnr Area   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Exter Qual     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Exter Cond     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Foundation     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Bsmt Qual      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Bsmt Cond      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Bsmt Exposure  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ BsmtFin Type 1 : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ BsmtFin SF 1   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ BsmtFin Type 2 : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ BsmtFin SF 2   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Bsmt Unf SF    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Total Bsmt SF  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Heating        : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Heating QC     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Central Air    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Electrical     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ 1st Flr SF     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ 2nd Flr SF     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Low Qual Fin SF: list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Gr Liv Area    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Bsmt Full Bath : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Bsmt Half Bath : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Full Bath      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Half Bath      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Bedroom AbvGr  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Kitchen AbvGr  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Kitchen Qual   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ TotRms AbvGrd  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Functional     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Fireplaces     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Fireplace Qu   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Garage Type    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Garage Yr Blt  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Garage Finish  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Garage Cars    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Garage Area    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Garage Qual    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Garage Cond    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Paved Drive    : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Wood Deck SF   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Open Porch SF  : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Enclosed Porch : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ 3Ssn Porch     : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Screen Porch   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Pool Area      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Pool QC        : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Fence          : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Misc Feature   : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Misc Val       : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Mo Sold        : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Yr Sold        : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   .. ..$ Sale Type      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ Sale Condition : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_character" "collector"
##   .. ..$ SalePrice      : list()
##   .. .. ..- attr(*, "class")= chr [1:2] "collector_integer" "collector"
##   ..$ default: list()
##   .. ..- attr(*, "class")= chr [1:2] "collector_guess" "collector"
##   ..- attr(*, "class")= chr "col_spec"
# gives you the structure of the data 
# Data types - how the data are stored in R
# Levels are categories

Min and Max of data

# use $ and variable name
min(ames$Lot_Frontage)
## [1] 0
max(ames$Lot_Frontage)
## [1] 313
ames

Range

range(ames$Lot_Area)
## [1]   1300 215245

Mean

mean(ames$Lot_Area)
## [1] 10147.92

Median

median(ames$Lot_Area)
## [1] 9436.5
## can also use quantile function
quantile(ames$Lot_Area, 0.5)
##    50% 
## 9436.5
quantile(ames$Lot_Area, 0.25)
##     25% 
## 7440.25
# can do with any quartiles 

Interquartile Range

# difference between first and third quartiles
IQR(ames$Lot_Area)
## [1] 4115

Standard Dev and Variance

sd(ames$Lot_Area)
## [1] 7880.018
var(ames$Lot_Area)
## [1] 62094680
## can also apply to multiple columns 

# can also try : ames[,c(“lot_area”,”lot_frontage")


lapply(ames[, 3:4], sd)
## $Lot_Frontage
## [1] 33.49944
## 
## $Lot_Area
## [1] 7880.018
# remember that lapply function applies a specific function to data --> i.e. (data you want, function you want)

Really helpful summary function

summary(ames[, 3:4])
##   Lot_Frontage       Lot_Area     
##  Min.   :  0.00   Min.   :  1300  
##  1st Qu.: 43.00   1st Qu.:  7440  
##  Median : 63.00   Median :  9436  
##  Mean   : 57.65   Mean   : 10148  
##  3rd Qu.: 78.00   3rd Qu.: 11555  
##  Max.   :313.00   Max.   :215245

Mode

Unfortunately, there is no function in R to find the mode of a variable (that I know of). Here’s one way I know of to do it.

table_ames <- table(ames$Lot_Area) # number of occurrences for each unique value
sort(table_ames, decreasing = TRUE) # sort highest to lowest
## 
##   9600   7200   6000   9000  10800   7500   8400   1680   6240   6120   7000 
##     44     43     34     29     25     21     21     18     18     17     13 
##   8125   9100   9750  10400   5400   8000   8640   2280   5000   8450   8750 
##     12     12     12     11     10     10     10      9      9      9      9 
##   9900  10000   3182   7800  10320   4435   8800   9350  10140  10200  10625 
##      9      9      8      8      8      7      7      7      7      7      7 
##  11250  11700   1890   3675   4500   6600   7018   8250   8520   9375  11050 
##      7      7      6      6      6      6      6      6      6      6      6 
##  13072   7750   7875   8064   8544   8760   8777  10237  10440  10530  11500 
##      6      5      5      5      5      5      5      5      5      5      5 
##   1533   2117   2308   2522   2544   2645   2665   3180   4426   4800   5925 
##      4      4      4      4      4      4      4      4      4      4      4 
##   6762   7150   7175   7700   8012   8050   8172   8480   8500   8712   9060 
##      4      4      4      4      4      4      4      4      4      4      4 
##   9200   9316   9360   9525   9571  10125  10410  10500  11000  11235  11645 
##      4      4      4      4      4      4      4      4      4      4      4 
##  11767  12000  12090  13125  13891   2160   3600   3907   4043   4224   5330 
##      4      4      4      4      4      3      3      3      3      3      3 
##   5500   5520   6300   7560   7590   8010   8094   8100   8248   8749   8773 
##      3      3      3      3      3      3      3      3      3      3      3 
##   8814   9084   9120   9240   9317   9720   9760   9825   9920   9965  10206 
##      3      3      3      3      3      3      3      3      3      3      3 
##  11075  11200  11340  11475  11600  11625  11800  11900  12900  13300  13500 
##      3      3      3      3      3      3      3      3      3      3      3 
##  13600  13693  14115  14175  15600  21780   1477   1526   1596   1936   1974 
##      3      3      3      3      3      3      2      2      2      2      2 
##   2364   2448   2998   3000   3010   3072   3196   3230   3500   3710   3811 
##      2      2      2      2      2      2      2      2      2      2      2 
##   3842   3843   3880   3922   3940   3951   4060   4280   4438   4571   4590 
##      2      2      2      2      2      2      2      2      2      2      2 
##   4928   5160   5350   5680   5700   6060   6285   6292   6305   6360   6410 
##      2      2      2      2      2      2      2      2      2      2      2 
##   6876   6882   6900   6931   6960   7024   7153   7155   7162   7180   7288 
##      2      2      2      2      2      2      2      2      2      2      2 
##   7301   7350   7390   7400   7420   7703   7740   7758   7804   7830   7892 
##      2      2      2      2      2      2      2      2      2      2      2 
##   7917   7920   7931   8145   8158   8197   8212   8235   8239   8314   8385 
##      2      2      2      2      2      2      2      2      2      2      2 
##   8398   8402   8405   8410   8470   8499   8550   8635   8658   8660   8700 
##      2      2      2      2      2      2      2      2      2      2      2 
##   8740   8741   8769   8816   8846   8850   8872   8877   8892   8899   8923 
##      2      2      2      2      2      2      2      2      2      2      2 
##   9020   9042   9045   9069   9135   9142   9144   9178   9187   9245   9260 
##      2      2      2      2      2      2      2      2      2      2      2 
##   9337   9373   9400   9450   9500   9520   9535   9591   9605   9627   9638 
##      2      2      2      2      2      2      2      2      2      2      2 
##   9650   9660   9675   9724   9780   9786   9790   9800   9802   9803   9819 
##      2      2      2      2      2      2      2      2      2      2      2 
##   9839   9842   9928   9937   9938  10010  10050  10084  10110  10120  10134 
##      2      2      2      2      2      2      2      2      2      2      2 
##  10141  10152  10240  10307  10335  10382  10452  10475  10480  10560  10574 
##      2      2      2      2      2      2      2      2      2      2      2 
##  10603  10628  10667  10762  10778  10791  10820  10890  10928  10936  10950 
##      2      2      2      2      2      2      2      2      2      2      2 
##  11003  11025  11029  11040  11070  11088  11100  11184  11194  11275  11426 
##      2      2      2      2      2      2      2      2      2      2      2 
##  11556  11616  11643  11664  11778  11792  11851  11988  12099  12144  12150 
##      2      2      2      2      2      2      2      2      2      2      2 
##  12155  12160  12180  12205  12328  12342  12350  12400  12438  12450  12633 
##      2      2      2      2      2      2      2      2      2      2      2 
##  12665  12704  12720  12774  13108  13200  13418  13650  13680  13695  13758 
##      2      2      2      2      2      2      2      2      2      2      2 
##  14000  14137  14330  14450  14803  15431  15611  15660  15750  16659  16770 
##      2      2      2      2      2      2      2      2      2      2      2 
##  17500  17871  21750   1300   1470   1476   1484   1488   1491   1495   1504 
##      2      2      2      1      1      1      1      1      1      1      1 
##   1612   1700   1733   1782   1869   1879   1894   1900   1920   1950   1953 
##      1      1      1      1      1      1      1      1      1      1      1 
##   2001   2016   2058   2104   2179   2205   2217   2268   2289   2304   2349 
##      1      1      1      1      1      1      1      1      1      1      1 
##   2368   2394   2403   2500   2529   2572   2592   2628   2651   2760   2880 
##      1      1      1      1      1      1      1      1      1      1      1 
##   2887   2938   2980   3013   3068   3087   3136   3153   3203   3215   3242 
##      1      1      1      1      1      1      1      1      1      1      1 
##   3300   3316   3363   3378   3435   3480   3515   3523   3604   3606   3612 
##      1      1      1      1      1      1      1      1      1      1      1 
##   3621   3628   3635   3636   3640   3672   3684   3696   3701   3735   3760 
##      1      1      1      1      1      1      1      1      1      1      1 
##   3768   3782   3784   3830   3840   3869   3874   3876   3901   3903   3950 
##      1      1      1      1      1      1      1      1      1      1      1 
##   3960   3964   3982   4000   4017   4045   4054   4058   4080   4084   4109 
##      1      1      1      1      1      1      1      1      1      1      1 
##   4113   4118   4130   4217   4230   4235   4251   4270   4274   4282   4330 
##      1      1      1      1      1      1      1      1      1      1      1 
##   4347   4379   4385   4388   4400   4403   4420   4447   4456   4480   4484 
##      1      1      1      1      1      1      1      1      1      1      1 
##   4485   4538   4608   4671   4712   4740   4750   4761   4765   4835   4853 
##      1      1      1      1      1      1      1      1      1      1      1 
##   4882   4899   4920   4923   4960   5001   5005   5062   5063   5070   5100 
##      1      1      1      1      1      1      1      1      1      1      1 
##   5105   5118   5119   5122   5142   5150   5175   5190   5220   5232   5250 
##      1      1      1      1      1      1      1      1      1      1      1 
##   5271   5280   5306   5310   5362   5381   5389   5395   5436   5470   5568 
##      1      1      1      1      1      1      1      1      1      1      1 
##   5586   5587   5600   5604   5633   5664   5684   5687   5707   5720   5747 
##      1      1      1      1      1      1      1      1      1      1      1 
##   5748   5775   5784   5790   5805   5814   5820   5825   5830   5852   5858 
##      1      1      1      1      1      1      1      1      1      1      1 
##   5868   5870   5890   5900   5911   5914   5940   5950   5976   6001   6012 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6040   6048   6125   6130   6155   6171   6173   6180   6191   6204   6221 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6264   6270   6289   6291   6324   6342   6371   6373   6380   6390   6400 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6402   6406   6420   6430   6435   6442   6449   6451   6472   6488   6490 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6500   6563   6565   6615   6627   6629   6710   6718   6720   6723   6756 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6760   6768   6780   6792   6820   6821   6845   6853   6854   6858   6860 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6897   6904   6911   6930   6950   6951   6953   6955   6956   6970   6978 
##      1      1      1      1      1      1      1      1      1      1      1 
##   6979   6993   7006   7007   7008   7010   7015   7020   7023   7030   7032 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7038   7040   7050   7052   7056   7060   7064   7082   7094   7100   7111 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7128   7130   7132   7134   7136   7176   7207   7223   7226   7227   7230 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7242   7244   7250   7252   7259   7264   7290   7296   7308   7311   7313 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7314   7315   7321   7328   7332   7340   7360   7379   7380   7388   7392 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7399   7404   7406   7407   7415   7424   7425   7436   7438   7440   7441 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7446   7449   7450   7472   7476   7480   7488   7506   7514   7518   7535 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7540   7550   7558   7570   7577   7584   7585   7588   7596   7599   7609 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7614   7626   7627   7628   7630   7632   7635   7642   7655   7658   7669 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7677   7681   7685   7689   7692   7697   7706   7711   7713   7728   7733 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7741   7742   7745   7755   7763   7777   7785   7791   7793   7795   7801 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7810   7819   7820   7822   7832   7837   7838   7840   7841   7844   7848 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7851   7861   7862   7879   7890   7898   7903   7910   7915   7922   7930 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7936   7937   7939   7942   7943   7945   7950   7976   7980   7984   7990 
##      1      1      1      1      1      1      1      1      1      1      1 
##   7993   8004   8013   8014   8020   8029   8035   8049   8063   8068   8070 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8072   8076   8078   8088   8089   8092   8098   8118   8120   8121   8123 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8127   8128   8139   8146   8147   8154   8155   8160   8163   8169   8170 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8174   8176   8190   8198   8199   8200   8220   8229   8232   8238   8240 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8243   8244   8246   8251   8263   8267   8280   8281   8285   8286   8294 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8298   8300   8304   8308   8320   8333   8334   8335   8339   8340   8366 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8368   8375   8382   8390   8393   8396   8413   8414   8425   8428   8430 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8433   8445   8453   8461   8462   8471   8472   8475   8487   8510   8512 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8513   8516   8521   8525   8529   8530   8532   8534   8536   8540   8546 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8556   8562   8574   8577   8581   8593   8600   8604   8626   8633   8637 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8638   8665   8668   8674   8680   8685   8688   8696   8702   8707   8723 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8724   8726   8730   8731   8736   8737   8738   8755   8765   8767   8772 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8775   8778   8780   8789   8791   8795   8803   8810   8820   8826   8834 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8838   8842   8847   8849   8854   8856   8857   8880   8883   8885   8900 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8910   8917   8918   8924   8925   8926   8927   8930   8935   8940   8944 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8960   8963   8965   8967   8969   8970   8973   8978   8982   8987   8990 
##      1      1      1      1      1      1      1      1      1      1      1 
##   8991   8993   8998   9017   9018   9019   9022   9024   9037   9044   9056 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9066   9073   9079   9085   9098   9101   9109   9116   9125   9129   9130 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9139   9140   9143   9150   9156   9157   9158   9170   9171   9179   9180 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9184   9196   9204   9205   9206   9215   9216   9230   9233   9236   9239 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9246   9247   9248   9250   9254   9259   9262   9272   9278   9280   9286 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9291   9297   9300   9303   9308   9313   9320   9340   9345   9353   9364 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9370   9382   9392   9399   9405   9416   9428   9430   9434   9439   9452 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9453   9457   9462   9464   9466   9468   9473   9477   9480   9482   9487 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9488   9490   9492   9503   9505   9510   9512   9531   9532   9533   9541 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9543   9545   9547   9548   9549   9550   9554   9555   9556   9560   9572 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9576   9587   9588   9590   9610   9612   9620   9636   9639   9649   9656 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9658   9662   9670   9671   9672   9680   9709   9717   9723   9729   9734 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9735   9736   9738   9742   9743   9757   9758   9759   9763   9764   9765 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9768   9770   9771   9783   9801   9808   9828   9830   9836   9840   9849 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9855   9856   9858   9863   9873   9880   9888   9892   9906   9910   9926 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9927   9930   9942   9945   9947   9950   9967   9978   9981   9986   9990 
##      1      1      1      1      1      1      1      1      1      1      1 
##   9991  10004  10005  10007  10011  10012  10019  10020  10021  10029  10032 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10037  10041  10042  10044  10083  10090  10106  10114  10122  10126  10130 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10142  10143  10147  10150  10159  10164  10170  10171  10172  10175  10176 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10179  10180  10182  10184  10186  10192  10197  10205  10207  10208  10215 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10226  10230  10235  10236  10246  10260  10261  10264  10265  10266  10267 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10274  10284  10289  10295  10300  10304  10316  10324  10331  10337  10355 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10356  10357  10364  10366  10367  10368  10380  10385  10386  10389  10395 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10402  10411  10420  10421  10425  10429  10434  10437  10441  10447  10448 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10454  10456  10457  10463  10464  10481  10482  10496  10512  10519  10532 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10533  10541  10542  10544  10547  10552  10557  10562  10566  10570  10573 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10592  10593  10594  10600  10612  10615  10616  10624  10632  10634  10635 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10637  10646  10650  10652  10655  10656  10659  10665  10672  10678  10680 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10682  10690  10708  10710  10712  10721  10725  10728  10732  10738  10739 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10750  10751  10759  10768  10769  10773  10780  10784  10790  10793  10816 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10818  10825  10832  10836  10839  10845  10846  10852  10858  10859  10872 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10880  10895  10896  10899  10900  10905  10914  10918  10920  10921  10926 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10927  10930  10933  10943  10944  10960  10970  10984  10990  10991  10994 
##      1      1      1      1      1      1      1      1      1      1      1 
##  10998  11002  11024  11027  11049  11058  11060  11064  11065  11067  11069 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11072  11080  11084  11096  11103  11104  11105  11120  11128  11134  11136 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11143  11146  11160  11166  11170  11175  11198  11202  11207  11210  11214 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11216  11218  11227  11228  11241  11248  11249  11287  11302  11305  11308 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11310  11316  11317  11327  11332  11333  11339  11341  11344  11345  11354 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11355  11358  11361  11362  11367  11375  11380  11382  11388  11394  11400 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11404  11409  11414  11419  11422  11423  11425  11428  11435  11443  11447 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11449  11454  11457  11478  11479  11492  11512  11515  11520  11526  11553 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11563  11577  11578  11584  11606  11613  11622  11631  11639  11646  11650 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11660  11670  11672  11675  11677  11679  11690  11692  11694  11717  11727 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11737  11750  11751  11762  11764  11765  11777  11782  11787  11796  11824 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11825  11830  11836  11838  11839  11841  11844  11846  11850  11855  11875 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11880  11883  11885  11888  11896  11911  11920  11923  11924  11927  11929 
##      1      1      1      1      1      1      1      1      1      1      1 
##  11932  11949  11950  11952  11957  11980  11999  12003  12011  12018  12030 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12046  12048  12085  12095  12102  12104  12108  12118  12122  12128  12134 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12137  12151  12168  12172  12182  12191  12192  12198  12203  12209  12216 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12217  12220  12224  12227  12228  12243  12244  12250  12256  12257  12274 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12285  12291  12292  12299  12304  12320  12327  12334  12352  12354  12358 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12361  12366  12375  12376  12378  12384  12388  12392  12393  12394  12395 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12416  12420  12435  12436  12444  12447  12456  12460  12461  12464  12469 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12474  12493  12508  12511  12513  12518  12537  12539  12546  12552  12568 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12585  12589  12606  12615  12640  12671  12677  12680  12692  12700  12702 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12712  12728  12732  12735  12760  12772  12778  12782  12798  12800  12803 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12822  12852  12853  12858  12864  12867  12878  12883  12886  12887  12888 
##      1      1      1      1      1      1      1      1      1      1      1 
##  12890  12891  12898  12919  12925  12929  12936  12961  12968  12984  13000 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13001  13005  13006  13008  13014  13015  13031  13041  13050  13052  13053 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13068  13069  13070  13101  13110  13128  13132  13142  13143  13159  13162 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13173  13175  13204  13214  13215  13250  13253  13260  13262  13265  13284 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13286  13339  13346  13350  13355  13360  13377  13383  13384  13400  13426 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13438  13440  13450  13472  13474  13478  13495  13501  13514  13515  13517 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13518  13526  13543  13560  13568  13587  13607  13615  13618  13641  13651 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13654  13673  13682  13688  13700  13704  13710  13728  13751  13770  13774 
##      1      1      1      1      1      1      1      1      1      1      1 
##  13811  13825  13830  13837  13860  13869  13870  13907  13975  14006  14054 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14067  14082  14100  14112  14122  14145  14149  14154  14157  14171  14190 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14191  14200  14210  14215  14217  14226  14230  14235  14250  14257  14260 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14267  14277  14299  14300  14303  14311  14331  14333  14357  14364  14375 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14418  14419  14442  14463  14536  14541  14559  14565  14572  14584  14585 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14587  14598  14601  14670  14680  14684  14694  14695  14720  14753  14762 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14774  14778  14780  14781  14828  14836  14850  14859  14860  14892  14948 
##      1      1      1      1      1      1      1      1      1      1      1 
##  14963  14977  15038  15138  15218  15240  15256  15262  15263  15274  15295 
##      1      1      1      1      1      1      1      1      1      1      1 
##  15300  15306  15312  15384  15387  15400  15401  15410  15417  15426  15428 
##      1      1      1      1      1      1      1      1      1      1      1 
##  15498  15523  15564  15576  15578  15584  15593  15602  15623  15635  15676 
##      1      1      1      1      1      1      1      1      1      1      1 
##  15783  15810  15863  15865  15870  15896  15922  15957  16012  16023  16033 
##      1      1      1      1      1      1      1      1      1      1      1 
##  16052  16056  16059  16133  16157  16158  16163  16196  16219  16226  16259 
##      1      1      1      1      1      1      1      1      1      1      1 
##  16269  16280  16285  16287  16300  16321  16381  16387  16451  16466  16492 
##      1      1      1      1      1      1      1      1      1      1      1 
##  16500  16545  16560  16561  16635  16647  16669  16692  16698  16737  16779 
##      1      1      1      1      1      1      1      1      1      1      1 
##  16870  16900  16905  17043  17082  17104  17120  17140  17169  17199  17217 
##      1      1      1      1      1      1      1      1      1      1      1 
##  17227  17242  17360  17400  17423  17433  17485  17503  17529  17541  17542 
##      1      1      1      1      1      1      1      1      1      1      1 
##  17597  17600  17671  17755  17778  17808  17920  17979  18000  18030  18044 
##      1      1      1      1      1      1      1      1      1      1      1 
##  18062  18160  18261  18265  18275  18386  18450  18494  18559  18600  18800 
##      1      1      1      1      1      1      1      1      1      1      1 
##  18837  18890  19138  19255  19296  19378  19508  19522  19550  19645  19690 
##      1      1      1      1      1      1      1      1      1      1      1 
##  19800  19900  19950  19958  20000  20062  20064  20270  20355  20431  20544 
##      1      1      1      1      1      1      1      1      1      1      1 
##  20693  20781  20896  21000  21281  21286  21299  21370  21384  21453  21533 
##      1      1      1      1      1      1      1      1      1      1      1 
##  21535  21579  21695  21872  21930  22002  22136  22420  22692  22950  23257 
##      1      1      1      1      1      1      1      1      1      1      1 
##  23303  23580  23595  23730  23920  24090  24572  24682  25000  25095  25286 
##      1      1      1      1      1      1      1      1      1      1      1 
##  25339  25419  25485  26073  26142  26178  26400  27650  27697  28698  29959 
##      1      1      1      1      1      1      1      1      1      1      1 
##  31220  31250  31770  32463  32668  33120  33983  34650  35133  35760  36500 
##      1      1      1      1      1      1      1      1      1      1      1 
##  39104  39290  39384  40094  41600  43500  45600  46589  47007  47280  50102 
##      1      1      1      1      1      1      1      1      1      1      1 
##  50271  51974  53107  53227  53504  56600  57200  63887  70761 115149 159000 
##      1      1      1      1      1      1      1      1      1      1      1 
## 164660 215245 
##      1      1
# although the printout is long, we can see that the mode for lot area is 9600

Counts

summary(ames$Bldg_Type)
##   OneFam TwoFmCon   Duplex    Twnhs   TwnhsE 
##     2425       62      109      101      233
# gives you the number of each factor in the data 

Conditional Counts for Nominal/Ordinal Variables

# lets say we want to count the number of each "paved"
summary(ames$Paved_Drive)
##      Dirt_Gravel Partial_Pavement            Paved 
##              216               62             2652
# another way to count the number of paved 
sum(ames$Paved_Drive == "Paved")
## [1] 2652
# or condition 
sum(ames$Paved_Drive == "Paved" | ames$Paved_Drive == "Dirt_Gravel")
## [1] 2868
# and condition 

sum(ames$Paved_Drive == "Paved" & ames$Paved_Drive == "Dirt_Gravel")
## [1] 0
sum(ames$Paved_Drive == "Paved" & ames$Alley == "No_Alley_Access")
## [1] 2518

Conditional Counts for Numeric Variables

# find the number of lots greater than 1000
sum(ames$Lot_Area > 1000, na.rm=TRUE)
## [1] 2930
# na.rm = TRUE removes missing values for you 
# find the number of lots between 1000 and 2000
sum(ames$Lot_Area > 1000 & ames$Lot_Area < 2000, na.rm=TRUE)
## [1] 57
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
ames2 = ames %>% mutate(filtered_area = ifelse(Lot_Area > 10000 & Lot_Area < 20000, 1, 0))%>%select(filtered_area, everything())

ames2
# now we have a variable at the end of our data set with this condition present 
library(dplyr)
ames2 = ames %>% mutate(filtered_area = ifelse(Lot_Area > 10000 & Lot_Area < 20000, 1, 0))%>%filter(filtered_area ==1)
ames2
# now we have a variable at the end of our data set with this condition present

Barplot

barplot(table(ames$Lot_Shape)) # table() is mandatory

# really basic automatic barplot in R 
# more fancy, customizable barplot in R
library(ggplot2)

ggplot(ames, aes(x = Lot_Shape, fill = Lot_Shape)) +
  geom_bar() +
  ggtitle("Lot Shape of Houses in Ames") +
  xlab("Lot Shape") + ylab("Number of Houses")

Line Plot

plot(ames$Lot_Area,
  type = "l"
) # "l" for line

Histogram

hist(ames$Lot_Frontage)

## can do same in ggplot 
ggplot(ames) +
  aes(x = Lot_Frontage) +
  geom_histogram(bins = 15)

# can change number of bins 

Boxplot

boxplot(ames$Lot_Frontage)

# side by side comparison of numerical to categorical 
boxplot(ames$Lot_Frontage ~ ames$Alley)

ggplot(ames) +
  aes(x = Alley, y = Lot_Frontage) +
  geom_boxplot()

Scatterplot

ames
plot(ames$Lot_Area, ames$Gr_Liv_Area)

ggplot(ames) +
  aes(x = ames$Lot_Area, y = ames$Gr_Liv_Area) +
  geom_point()
## Warning: Use of `ames$Lot_Area` is discouraged. Use `Lot_Area` instead.
## Warning: Use of `ames$Gr_Liv_Area` is discouraged. Use `Gr_Liv_Area` instead.

# add in a categorical factor for more info 
ggplot(ames) +
  aes(x = ames$Lot_Area, y = ames$Gr_Liv_Area, color = Alley) +
  geom_point() +
  scale_color_hue()
## Warning: Use of `ames$Lot_Area` is discouraged. Use `Lot_Area` instead.
## Warning: Use of `ames$Gr_Liv_Area` is discouraged. Use `Gr_Liv_Area` instead.

QQplot for Normality Assumptions

# Draw points on the qq-plot:
qqnorm(ames$Lot_Area)
# Draw the reference line:
qqline(ames$Lot_Area)

We can see that this deviates a lot from normality (the theoretical line of normal data), so this normality assumption would be broken.

Density plots for distribution

plot(density(ames$Lot_Area))